{extend name="layout/layout"/}
{block name="body"}
<body data-type="widgets">
{/block}
{block name="content"}
<!-- 内容区域 -->
<div class="tpl-content-wrapper">
    <div class="row-content am-cf">
        <div class="row">
            <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                <div class="widget am-cf">
                    <div class="widget-head am-cf">
                        <div class="widget-title  am-cf">会员列表</div>
                    </div>
                    <div class="widget-body  am-fr">
                        <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                            <div class="am-form-group">
                                <div class="am-btn-toolbar">
                                    <div class="am-btn-group am-btn-group-xs">
                                     <!--   <button type="button" class="am-btn am-btn-default am-btn-success"><span class="am-icon-plus"></span> 新增</button>
                                        <button type="button" class="am-btn am-btn-default am-btn-secondary"><span class="am-icon-save"></span> 保存</button>
                                        <button type="button" class="am-btn am-btn-default am-btn-warning"><span class="am-icon-archive"></span> 审核</button>
                                        <button type="button" class="am-btn am-btn-default am-btn-danger"><span class="am-icon-trash-o"></span> 删除</button>-->
                                    </div>
                                </div>
                            </div>
                        </div>
                        <form action="{:url('@list')}" method="POST">
                       <div class="am-u-sm-12 am-u-md-6 am-u-lg-3">
                            <div class="am-form-group tpl-table-list-select">
                                <select class="data-type js-category" name="category" data-am-selected="{btnSize: 'sm'}" >
                                    <option value="all"  >所有地区</option>
                                    <option value="首页会员" >首页会员</option>

                                </select>
                            </div>
                        </div>
                        <div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
                            <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                                <input type="text"  name="mobile" class="am-form-field "  placeholder="请输入手机号码">
                                        <span class="am-input-group-btn">
            <button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search" type="submit"></button>
          </span>
                            </div>
                        </div>
                        </form>
                        <div class="am-u-sm-12">
                            <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black " id="example-r">
                                <thead>
                                <tr>
                                    <th>会员名</th>
                                    <th>手机号码</th>
                                    <th>城市</th>
                                    <th>区县</th>
                                    <th>小区</th>
                                    <th>新旧</th>
                                    <th>住房面积</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {foreach name="data" item="val"}
                                <tr class="gradeX">
                                    <td>{$val.member_name} </td>
                                    <td>{$val.member_mobile}  </td>
                                    <td>{$val.member_city} </td>
                                    <td>{$val.member_area}</td>
                                    <td>{$val.member_plot}</td>
                                    <td>{$val.member_status}</td>
                                    <td>{$val.member_size}</td>
                                    <td>
                                        <div class="tpl-table-black-operation">
                                            <a href="javascript:;"  data-id="{$val.member_id}"  onclick="changeState(this)">
                                                {$val.member_state}
                                            </a>
                                            <a href="{:url('@list/edit',['id'=>$val.member_id])}"  >
                                                <i class="am-icon-pencil"></i> 编辑
                                            </a>
                                            <a href="javascript:;" class="tpl-table-black-operation-del" data-id="{$val.member_id}"  onclick="deleted(this)" >
                                                <i class="am-icon-trash"></i> 删除
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                                {/foreach}

                                <!-- more data -->
                                </tbody>
                            </table>
                        </div>

                        <div class="am-u-lg-12 am-cf">

                            <div class="am-fr">
                                {$list->render()}
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(document).ready(function(){
        $('option').removeAttr('selected');
        $('option[value="{$category}"]').attr('selected','selected');
        $('input[name="mobile"]').attr('value','{$mobile}')
    })

    function changeState(obj){
        var id=obj.attributes['data-id'].value;
        $.ajax({
            url:"{:url('@change')}",
            type:'post',
            dataType:'json',
            data:{
                id:id
            },
            async:false,
            success:function(data){
                if(data=='修改失败'){
                    layer.msg('修改失败', {icon:5});
                    return false;
                }

                obj.innerText=data;
               // alert(data);
            }
        })
    }
    function deleted(obj){
        var id=obj.attributes['data-id'].value;
        layer.confirm('确定删除?', function(index){
            //do something
            $.ajax({
                data:{
                    id:id,
                },
                dataType:'json',
                async:false,
                type:'post',
                url:"{:url('@memberDel')}",
                success:function(data){
                    if(data == 1){
                        layer.msg('删除成功',{icon:1});
                        setTimeout(function(){
                            window.history.go(0);
                        },1000);
                    }else{
                        layer.msg('删除失败',{icon:5})
                    }
                }
            })
            layer.close(index);
        });
    }


</script>


{/block}
